package torque.generated;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.map.TableMap;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;





/**
 * casee d un echiquier
 *
 * This class was autogenerated by Torque on:
 *
 * [Wed Oct 16 17:21:00 CEST 2013]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Casee
 */
public abstract class BaseCasee extends BaseObject
{
    /** Serial version */
    private static final long serialVersionUID = 1381936860962L;

    /** The Peer class */
    private static final CaseePeer peer =
        new CaseePeer();


    /** The value for the x field */
    private int x;

    /** The value for the y field */
    private int y;

    /** The value for the nomtroll field */
    private String nomtroll;

    /** The value for the idEchiquier field */
    private String idEchiquier;


    /**
     * Get the X
     *
     * @return int
     */
    public int getX()
    {
        return x;
    }


    /**
     * Set the value of X
     *
     * @param v new value
     */
    public void setX(int v) throws TorqueException
    {

        if (this.x != v)
        {
            this.x = v;
            setModified(true);
        }



        // update associated Place
        if (collPlaces != null)
        {
            for (int i = 0; i < collPlaces.size(); i++)
            {
                ((Place) collPlaces.get(i))
                        .setX(v);
            }
        }
    }

    /**
     * Get the Y
     *
     * @return int
     */
    public int getY()
    {
        return y;
    }


    /**
     * Set the value of Y
     *
     * @param v new value
     */
    public void setY(int v) throws TorqueException
    {

        if (this.y != v)
        {
            this.y = v;
            setModified(true);
        }



        // update associated Place
        if (collPlaces != null)
        {
            for (int i = 0; i < collPlaces.size(); i++)
            {
                ((Place) collPlaces.get(i))
                        .setY(v);
            }
        }
    }

    /**
     * Get the Nomtroll
     *
     * @return String
     */
    public String getNomtroll()
    {
        return nomtroll;
    }


    /**
     * Set the value of Nomtroll
     *
     * @param v new value
     */
    public void setNomtroll(String v) throws TorqueException
    {

        if (!ObjectUtils.equals(this.nomtroll, v))
        {
            this.nomtroll = v;
            setModified(true);
        }


        if (aTroll != null && !ObjectUtils.equals(aTroll.getNom(), v))
        {
            aTroll = null;
        }

    }

    /**
     * Get the IdEchiquier
     *
     * @return String
     */
    public String getIdEchiquier()
    {
        return idEchiquier;
    }


    /**
     * Set the value of IdEchiquier
     *
     * @param v new value
     */
    public void setIdEchiquier(String v) throws TorqueException
    {

        if (!ObjectUtils.equals(this.idEchiquier, v))
        {
            this.idEchiquier = v;
            setModified(true);
        }


        if (aEchiquier != null && !ObjectUtils.equals(aEchiquier.getIdEchiquier(), v))
        {
            aEchiquier = null;
        }


        // update associated Place
        if (collPlaces != null)
        {
            for (int i = 0; i < collPlaces.size(); i++)
            {
                ((Place) collPlaces.get(i))
                        .setIdEchiquier(v);
            }
        }
    }

    



    private Echiquier aEchiquier;

    /**
     * Declares an association between this object and a Echiquier object
     *
     * @param v Echiquier
     * @throws TorqueException
     */
    public void setEchiquier(Echiquier v) throws TorqueException
    {
        if (v == null)
        {
            setIdEchiquier((String) null);
        }
        else
        {
            setIdEchiquier(v.getIdEchiquier());
        }
        aEchiquier = v;
    }


    /**
     * Returns the associated Echiquier object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Echiquier object
     * @throws TorqueException
     */
    public Echiquier getEchiquier()
        throws TorqueException
    {
        if (aEchiquier == null && (!ObjectUtils.equals(this.idEchiquier, null)))
        {
            aEchiquier = EchiquierPeer.retrieveByPK(SimpleKey.keyFor(this.idEchiquier));
        }
        return aEchiquier;
    }

    /**
     * Return the associated Echiquier object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Echiquier object
     * @throws TorqueException
     */
    public Echiquier getEchiquier(Connection connection)
        throws TorqueException
    {
        if (aEchiquier == null && (!ObjectUtils.equals(this.idEchiquier, null)))
        {
            aEchiquier = EchiquierPeer.retrieveByPK(SimpleKey.keyFor(this.idEchiquier), connection);
        }
        return aEchiquier;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setEchiquierKey(ObjectKey key) throws TorqueException
    {

        setIdEchiquier(key.toString());
    }




    private Troll aTroll;

    /**
     * Declares an association between this object and a Troll object
     *
     * @param v Troll
     * @throws TorqueException
     */
    public void setTroll(Troll v) throws TorqueException
    {
        if (v == null)
        {
            setNomtroll((String) null);
        }
        else
        {
            setNomtroll(v.getNom());
        }
        aTroll = v;
    }


    /**
     * Returns the associated Troll object.
     * If it was not retrieved before, the object is retrieved from
     * the database
     *
     * @return the associated Troll object
     * @throws TorqueException
     */
    public Troll getTroll()
        throws TorqueException
    {
        if (aTroll == null && (!ObjectUtils.equals(this.nomtroll, null)))
        {
            aTroll = TrollPeer.retrieveByPK(SimpleKey.keyFor(this.nomtroll));
        }
        return aTroll;
    }

    /**
     * Return the associated Troll object
     * If it was not retrieved before, the object is retrieved from
     * the database using the passed connection
     *
     * @param connection the connection used to retrieve the associated object
     *        from the database, if it was not retrieved before
     * @return the associated Troll object
     * @throws TorqueException
     */
    public Troll getTroll(Connection connection)
        throws TorqueException
    {
        if (aTroll == null && (!ObjectUtils.equals(this.nomtroll, null)))
        {
            aTroll = TrollPeer.retrieveByPK(SimpleKey.keyFor(this.nomtroll), connection);
        }
        return aTroll;
    }

    /**
     * Provides convenient way to set a relationship based on a
     * ObjectKey, for example
     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
     *
     */
    public void setTrollKey(ObjectKey key) throws TorqueException
    {

        setNomtroll(key.toString());
    }
   


    /**
     * Collection to store aggregation of collPlaces
     */
    protected List collPlaces;

    /**
     * Temporary storage of collPlaces to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initPlaces()
    {
        if (collPlaces == null)
        {
            collPlaces = new ArrayList();
        }
    }


    /**
     * Method called to associate a Place object to this object
     * through the Place foreign key attribute
     *
     * @param l Place
     * @throws TorqueException
     */
    public void addPlace(Place l) throws TorqueException
    {
        getPlaces().add(l);
        l.setCasee((Casee) this);
    }

    /**
     * Method called to associate a Place object to this object
     * through the Place foreign key attribute using connection.
     *
     * @param l Place
     * @throws TorqueException
     */
    public void addPlace(Place l, Connection con) throws TorqueException
    {
        getPlaces(con).add(l);
        l.setCasee((Casee) this);
    }

    /**
     * The criteria used to select the current contents of collPlaces
     */
    private Criteria lastPlacesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPlaces(new Criteria())
     *
     * @return the collection of associated objects
     * @throws TorqueException
     */
    public List getPlaces()
        throws TorqueException
    {
        if (collPlaces == null)
        {
            collPlaces = getPlaces(new Criteria(10));
        }
        return collPlaces;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Casee has previously
     * been saved, it will retrieve related Places from storage.
     * If this Casee is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getPlaces(Criteria criteria) throws TorqueException
    {
        if (collPlaces == null)
        {
            if (isNew())
            {
               collPlaces = new ArrayList();
            }
            else
            {
                criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier() );
                criteria.add(PlacePeer.X, getX() );
                criteria.add(PlacePeer.Y, getY() );
                collPlaces = PlacePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                criteria.add(PlacePeer.X, getX());
                criteria.add(PlacePeer.Y, getY());
                if (!lastPlacesCriteria.equals(criteria))
                {
                    collPlaces = PlacePeer.doSelect(criteria);
                }
            }
        }
        lastPlacesCriteria = criteria;

        return collPlaces;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPlaces(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPlaces(Connection con) throws TorqueException
    {
        if (collPlaces == null)
        {
            collPlaces = getPlaces(new Criteria(10), con);
        }
        return collPlaces;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Casee has previously
     * been saved, it will retrieve related Places from storage.
     * If this Casee is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPlaces(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collPlaces == null)
        {
            if (isNew())
            {
               collPlaces = new ArrayList();
            }
            else
            {
                 criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                 criteria.add(PlacePeer.X, getX());
                 criteria.add(PlacePeer.Y, getY());
                 collPlaces = PlacePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                 criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                 criteria.add(PlacePeer.X, getX());
                 criteria.add(PlacePeer.Y, getY());
                 if (!lastPlacesCriteria.equals(criteria))
                 {
                     collPlaces = PlacePeer.doSelect(criteria, con);
                 }
             }
         }
         lastPlacesCriteria = criteria;

         return collPlaces;
     }











    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Casee is new, it will return
     * an empty collection; or if this Casee has previously
     * been saved, it will retrieve related Places from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Casee.
     */
    protected List getPlacesJoinPartie(Criteria criteria)
        throws TorqueException
    {
        if (collPlaces == null)
        {
            if (isNew())
            {
               collPlaces = new ArrayList();
            }
            else
            {
                criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                criteria.add(PlacePeer.X, getX());
                criteria.add(PlacePeer.Y, getY());
                collPlaces = PlacePeer.doSelectJoinPartie(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
            criteria.add(PlacePeer.X, getX());
            criteria.add(PlacePeer.Y, getY());
            if (!lastPlacesCriteria.equals(criteria))
            {
                collPlaces = PlacePeer.doSelectJoinPartie(criteria);
            }
        }
        lastPlacesCriteria = criteria;

        return collPlaces;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Casee is new, it will return
     * an empty collection; or if this Casee has previously
     * been saved, it will retrieve related Places from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Casee.
     */
    protected List getPlacesJoinObjets(Criteria criteria)
        throws TorqueException
    {
        if (collPlaces == null)
        {
            if (isNew())
            {
               collPlaces = new ArrayList();
            }
            else
            {
                criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                criteria.add(PlacePeer.X, getX());
                criteria.add(PlacePeer.Y, getY());
                collPlaces = PlacePeer.doSelectJoinObjets(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
            criteria.add(PlacePeer.X, getX());
            criteria.add(PlacePeer.Y, getY());
            if (!lastPlacesCriteria.equals(criteria))
            {
                collPlaces = PlacePeer.doSelectJoinObjets(criteria);
            }
        }
        lastPlacesCriteria = criteria;

        return collPlaces;
    }









    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this Casee is new, it will return
     * an empty collection; or if this Casee has previously
     * been saved, it will retrieve related Places from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in Casee.
     */
    protected List getPlacesJoinCasee(Criteria criteria)
        throws TorqueException
    {
        if (collPlaces == null)
        {
            if (isNew())
            {
               collPlaces = new ArrayList();
            }
            else
            {
                criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
                criteria.add(PlacePeer.X, getX());
                criteria.add(PlacePeer.Y, getY());
                collPlaces = PlacePeer.doSelectJoinCasee(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            criteria.add(PlacePeer.ID_ECHIQUIER, getIdEchiquier());
            criteria.add(PlacePeer.X, getX());
            criteria.add(PlacePeer.Y, getY());
            if (!lastPlacesCriteria.equals(criteria))
            {
                collPlaces = PlacePeer.doSelectJoinCasee(criteria);
            }
        }
        lastPlacesCriteria = criteria;

        return collPlaces;
    }



        
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
            fieldNames.add("X");
            fieldNames.add("Y");
            fieldNames.add("Nomtroll");
            fieldNames.add("IdEchiquier");
            fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by field (Java) name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
        if (name.equals("X"))
        {
            return new Integer(getX());
        }
        if (name.equals("Y"))
        {
            return new Integer(getY());
        }
        if (name.equals("Nomtroll"))
        {
            return getNomtroll();
        }
        if (name.equals("IdEchiquier"))
        {
            return getIdEchiquier();
        }
        return null;
    }

    /**
     * Set a field in the object by field (Java) name.
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByName(String name, Object value )
        throws TorqueException, IllegalArgumentException
    {
        if (name.equals("X"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setX(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Y"))
        {
            if (value == null || ! (Integer.class.isInstance(value)))
            {
                throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
            }
            setY(((Integer) value).intValue());
            return true;
        }
        if (name.equals("Nomtroll"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setNomtroll((String) value);
            return true;
        }
        if (name.equals("IdEchiquier"))
        {
            // Object fields can be null
            if (value != null && ! String.class.isInstance(value))
            {
                throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
            }
            setIdEchiquier((String) value);
            return true;
        }
        return false;
    }

    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
        if (name.equals(CaseePeer.X))
        {
            return new Integer(getX());
        }
        if (name.equals(CaseePeer.Y))
        {
            return new Integer(getY());
        }
        if (name.equals(CaseePeer.NOMTROLL))
        {
            return getNomtroll();
        }
        if (name.equals(CaseePeer.ID_ECHIQUIER))
        {
            return getIdEchiquier();
        }
        return null;
    }

    /**
     * Set field values by Peer Field Name
     *
     * @param name field name
     * @param value field value
     * @return True if value was set, false if not (invalid name / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPeerName(String name, Object value)
        throws TorqueException, IllegalArgumentException
    {
      if (CaseePeer.X.equals(name))
        {
            return setByName("X", value);
        }
      if (CaseePeer.Y.equals(name))
        {
            return setByName("Y", value);
        }
      if (CaseePeer.NOMTROLL.equals(name))
        {
            return setByName("Nomtroll", value);
        }
      if (CaseePeer.ID_ECHIQUIER.equals(name))
        {
            return setByName("IdEchiquier", value);
        }
        return false;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
        if (pos == 0)
        {
            return new Integer(getX());
        }
        if (pos == 1)
        {
            return new Integer(getY());
        }
        if (pos == 2)
        {
            return getNomtroll();
        }
        if (pos == 3)
        {
            return getIdEchiquier();
        }
        return null;
    }

    /**
     * Set field values by its position (zero based) in the XML schema.
     *
     * @param position The field position
     * @param value field value
     * @return True if value was set, false if not (invalid position / protected field).
     * @throws IllegalArgumentException if object type of value does not match field object type.
     * @throws TorqueException If a problem occurs with the set[Field] method.
     */
    public boolean setByPosition(int position, Object value)
        throws TorqueException, IllegalArgumentException
    {
    if (position == 0)
        {
            return setByName("X", value);
        }
    if (position == 1)
        {
            return setByName("Y", value);
        }
    if (position == 2)
        {
            return setByName("Nomtroll", value);
        }
    if (position == 3)
        {
            return setByName("IdEchiquier", value);
        }
        return false;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
        save(CaseePeer.DATABASE_NAME);
    }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
        try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
    }

    /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
        {
            alreadyInSave = true;



            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    CaseePeer.doInsert((Casee) this, con);
                    setNew(false);
                }
                else
                {
                    CaseePeer.doUpdate((Casee) this, con);
                }
            }


            if (collPlaces != null)
            {
                for (int i = 0; i < collPlaces.size(); i++)
                {
                    ((Place) collPlaces.get(i)).save(con);
                }
            }
            alreadyInSave = false;
        }
    }



    private final SimpleKey[] pks = new SimpleKey[3];
    private final ComboKey comboPK = new ComboKey(pks);

    /**
     * Set the PrimaryKey with an ObjectKey
     *
     * @param key
     */
    public void setPrimaryKey(ObjectKey key) throws TorqueException
    {
        SimpleKey[] keys = (SimpleKey[]) key.getValue();
        setX(((NumberKey)keys[0]).intValue());
        setY(((NumberKey)keys[1]).intValue());
        setIdEchiquier(keys[2].toString());
    }

    /**
     * Set the PrimaryKey using SimpleKeys.
     *
     * @param x int
     * @param y int
     * @param idEchiquier String
     */
    public void setPrimaryKey( int x, int y, String idEchiquier)
        throws TorqueException
    {
        setX(x);
        setY(y);
        setIdEchiquier(idEchiquier);
    }

    /**
     * Set the PrimaryKey using a String.
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setPrimaryKey(new ComboKey(key));
    }

    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        pks[0] = SimpleKey.keyFor(getX());
        pks[1] = SimpleKey.keyFor(getY());
        pks[2] = SimpleKey.keyFor(getIdEchiquier());
        return comboPK;
    }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public Casee copy() throws TorqueException
    {
        return copy(true);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     *
     * @param con the database connection to read associated objects.
     */
    public Casee copy(Connection con) throws TorqueException
    {
        return copy(true, con);
    }

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     */
    public Casee copy(boolean deepcopy) throws TorqueException
    {
        return copyInto(new Casee(), deepcopy);
    }

    /**
     * Makes a copy of this object using connection.
     * It creates a new object filling in the simple attributes.
     * If the parameter deepcopy is true, it then fills all the
     * association collections and sets the related objects to
     * isNew=true.
     *
     * @param deepcopy whether to copy the associated objects.
     * @param con the database connection to read associated objects.
     */
    public Casee copy(boolean deepcopy, Connection con) throws TorqueException
    {
        return copyInto(new Casee(), deepcopy, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     */
    protected Casee copyInto(Casee copyObj) throws TorqueException
    {
        return copyInto(copyObj, true);
    }

  
    /**
     * Fills the copyObj with the contents of this object using connection.
     * The associated objects are also copied and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param con the database connection to read associated objects.
     */
    protected Casee copyInto(Casee copyObj, Connection con) throws TorqueException
    {
        return copyInto(copyObj, true, con);
    }
  
    /**
     * Fills the copyObj with the contents of this object.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     */
    protected Casee copyInto(Casee copyObj, boolean deepcopy) throws TorqueException
    {
        copyObj.setX(x);
        copyObj.setY(y);
        copyObj.setNomtroll(nomtroll);
        copyObj.setIdEchiquier(idEchiquier);

        copyObj.setX( 0);
        copyObj.setY( 0);
        copyObj.setIdEchiquier((String)null);

        if (deepcopy)
        {


        List vPlaces = getPlaces();
        if (vPlaces != null)
        {
            for (int i = 0; i < vPlaces.size(); i++)
            {
                Place obj = (Place) vPlaces.get(i);
                copyObj.addPlace(obj.copy());
            }
        }
        else
        {
            copyObj.collPlaces = null;
        }
        }
        return copyObj;
    }
        
    
    /**
     * Fills the copyObj with the contents of this object using connection.
     * If deepcopy is true, The associated objects are also copied
     * and treated as new objects.
     *
     * @param copyObj the object to fill.
     * @param deepcopy whether the associated objects should be copied.
     * @param con the database connection to read associated objects.
     */
    protected Casee copyInto(Casee copyObj, boolean deepcopy, Connection con) throws TorqueException
    {
        copyObj.setX(x);
        copyObj.setY(y);
        copyObj.setNomtroll(nomtroll);
        copyObj.setIdEchiquier(idEchiquier);

        copyObj.setX( 0);
        copyObj.setY( 0);
        copyObj.setIdEchiquier((String)null);

        if (deepcopy)
        {


        List vPlaces = getPlaces(con);
        if (vPlaces != null)
        {
            for (int i = 0; i < vPlaces.size(); i++)
            {
                Place obj = (Place) vPlaces.get(i);
                copyObj.addPlace(obj.copy(con), con);
            }
        }
        else
        {
            copyObj.collPlaces = null;
        }
        }
        return copyObj;
    }
    
    

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public CaseePeer getPeer()
    {
        return peer;
    }

    /**
     * Retrieves the TableMap object related to this Table data without
     * compiler warnings of using getPeer().getTableMap().
     *
     * @return The associated TableMap object.
     */
    public TableMap getTableMap() throws TorqueException
    {
        return CaseePeer.getTableMap();
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Casee:\n");
        str.append("X = ")
           .append(getX())
           .append("\n");
        str.append("Y = ")
           .append(getY())
           .append("\n");
        str.append("Nomtroll = ")
           .append(getNomtroll())
           .append("\n");
        str.append("IdEchiquier = ")
           .append(getIdEchiquier())
           .append("\n");
        return(str.toString());
    }
}
